<?php
/**
 *CommentController
 * @author tan bing
 * @date 2021-11-15 9:39
 */


namespace Modules\Order\Http\Controllers\Api;


use Modules\Order\Services\Api\CommentServices;

class CommentController extends ApiBaseController
{

    /**
     * @var CommentServices
     * @author tan bing
     */
    private CommentServices $commentServices;

    /**
     * CommentController constructor.
     * @param CommentServices $commentServices
     * @author tan bing
     * @date 2021-11-15 9:58
     */
    public function __construct(CommentServices $commentServices)
    {
        $this->commentServices = $commentServices;
    }

    /**
     * 订单评论预览页面
     * @return mixed
     * @author tan bing
     * @date 2021-11-15 9:57
     */
    public function commentPreview()
    {
        try {
            $result = $this->commentServices->commentPreview();
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }
        return $this->success($result);
    }

    /**
     * 订单评价
     * @return mixed
     * @throws \Throwable
     * @author tan bing
     * @date 2021-11-15 10:52
     */
    public function comment()
    {
        try {
            $result = $this->commentServices->comment();
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }
        return $this->success($result);
    }
}